/*
 * This file is a part of the RMI Plugin for Eclipse tutorials.
 * Copyright (C) 2002-7 Genady Beryozkin
 */
package l3.info.Projet.Serveur;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

import l3.info.Projet.Client.Utilisateur;
import l3.info.Projet.RMI.RequettesReseau;
//import java.util.HashSet;

//import java.util.HashSet;

/**
 * This is a simulation of a printer server. Note that in real application,
 * server level synchronization may be needed.
 * 
 * @Aboulkacem Hamid
 */
public class ServeurRequettes extends UnicastRemoteObject implements
		RequettesReseau {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8089327397449448283L;
	private String name;

	public ServeurRequettes(String name) throws RemoteException {
		this.name = name;
		try {
			Registry registry = LocateRegistry.getRegistry();
			registry.rebind(this.name, this);
		} catch (RemoteException e) {
			System.err.println("Unexcepted remote error.");
			e.printStackTrace();
			System.exit(-1); // can't just return, rmi threads may not exit
		}
		System.out.println("Le serveur est lanc� correctement");
	}

	//public int somme(int x, int y) throws RemoteException {
		//System.out
			//	.println("Serveur: j'ai recu deux valeurs: " + x + " et " + y);
		//return x + y;
	//}
	
	public void printUtilisateur (Utilisateur u) throws RemoteException{
		System.out.println(u);
	}

}